from mapreduce import base_handler
from mapreduce import mapper_pipeline
  
def model_serializing_mapper(entity):
  """Serializes input models as protocol buffers."""
  yield entity.ToPb()

class DatastoreDumpPipeline(base_handler.PipelineBase):
  def run(self, mapreduce_name, kind, shards):
    output = yield mapper_pipeline.MapperPipeline(
        mapreduce_name,
        'gatling.mapper.model_serializing_mapper',
        'google.appengine.ext.mapreduce.input_readers.DatastoreEntityInputReader',
        'google.appengine.ext.mapreduce.output_writers.BlobstoreRecordsOutputWriter',
        params={
          'entity_kind': kind,
        },
        shards=shards)
